package com.yingyi.user.controller;

import com.yingyi.basic.exception.BusinessException;
import com.yingyi.basic.util.JsonResult;
import com.yingyi.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/logout")
public class LogoutController {

    @Autowired
    private IUserService userService;

    @GetMapping("/{token}")
    public JsonResult logout(@PathVariable String token){
        try {
           userService.logout(token);
           return JsonResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.me().setMessage("网络异常，请稍后重试");
        }
    }
}
